package cn.wizzer.app.user.modules.models;

import cn.wizzer.framework.base.model.BaseModel;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;

import java.io.Serializable;

/**
 * 用户收货地址
 */
@Data
@Table("user_address")
public class UserAddress extends BaseModel implements Serializable {

    @Column
    @Name
    @Comment("ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    @PrevInsert(els = {@EL("uuid()")})
    private String id;

    @Column
    @Comment("用户ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String userId;

    @Column
    @Comment("收货人")
    @ColDefine(type = ColType.VARCHAR, width = 20)
    private String receiverName;

    @Column
    @Comment("收货人电话")
    @ColDefine(type = ColType.VARCHAR, width = 11)
    private String receiverPhone;

    /**
     * 直接存成一整串
     * 如：北京市丰台区建银酒店502室
     */
    @Column
    @Comment("地址")
    @ColDefine(type = ColType.VARCHAR, width = 128)
    private String addr;

    @Column
    @Comment("操作时间")
    @PrevInsert(els = @EL("$me.now()"))
    //Long不要用ColDefine定义,兼容oracle/mysql,支持2038年以后的时间戳
    private Long upAt;

    @Column
    @Comment("默认地址")
    @ColDefine(type = ColType.BOOLEAN)
    private boolean addr_default;
}
